#region Namespace References

using System;
using DynConDevCorp.OpenArch.SmartData.Interfaces;

#endregion

namespace DynConDevCorp.OpenArch.SmartData.Core.Metadata
{
    /// <summary>
    /// Top level class for all management of Smart Metadata
    /// </summary>
    public class SmartMetadataManager
    {
        #region Constructors

        private SmartMetadataManager()
        {
        }

        #endregion

        #region Public Static Properties

        /// <summary>
        /// Gets the global.
        /// </summary>
        /// <value>The global.</value>
        public static SmartMetadataManager Global
        {
            get { return s_GlobalInstance; }
        }

        #endregion

        #region Public Instance Methods

        /// <summary>
        /// Registers the auto fields.
        /// </summary>
        /// <typeparam name="TEntity">The type of the NTIT y_ TYPE.</typeparam>
        /// <param name="instance">The instance.</param>
        public void RegisterAutoFields<TEntity>(TEntity instance)
            where TEntity : ISmartEntity
        {
            Type entityType = instance.GetType();
            SmartMetaEntity smartMetaEntity = SmartMetaDataStore.GlobalInstance.GetMetaEntity(entityType);
            smartMetaEntity.Initialize(instance);
        }

        #endregion

        #region Fields and Constants

        private static readonly SmartMetadataManager s_GlobalInstance = new SmartMetadataManager();

        #endregion
    }
}